package com.xuetang9.t9.hotel.services.impl;

import com.xuetang9.t9.hotel.beans.EStaffinfo;
import com.xuetang9.t9.hotel.mapper.EStaffinfoMapper;
import com.xuetang9.t9.hotel.services.IStaffinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * @ClassName IStaffinfoService
 * @Description TODO
 * @Author qin
 * @Date 2020/2/25 10:16
 * @Version 1.0
 **/
@Service
public class StaffinfoService implements IStaffinfoService {
    @Autowired
    private EStaffinfoMapper staffinfoMapper;


    @Override
    public List<EStaffinfo> queryStaffList() {
        return  staffinfoMapper.queryStaffList();
    }

    @Override
    public boolean insertStaff(EStaffinfo staffinfo) throws ParseException {
        return staffinfoMapper.insertStaff(staffinfo.getId(),staffinfo.getName(),staffinfo.getSex(),staffinfo.getPhonenum(),staffinfo.getRank(),staffinfo.getLoginnum(),staffinfo.getLoginpass(),staffinfo.getCardnum(),new SimpleDateFormat("yyyy-MM-dd").parse(staffinfo.getBrithdate()))>0;
    }

    @Override
    public boolean updateStaff(EStaffinfo staffinfo) throws ParseException {
        return staffinfoMapper.updateStaff(staffinfo.getId(),staffinfo.getName(),staffinfo.getSex(),staffinfo.getPhonenum(),staffinfo.getRank(),staffinfo.getLoginnum(),staffinfo.getLoginpass(),staffinfo.getCardnum(),new SimpleDateFormat("yyyy-MM-dd").parse(staffinfo.getBrithdate()))>0;
    }

    @Override
    public boolean deleteStaff(int id) {
        return staffinfoMapper.deleteStaff(id)>0;
    }

    @Override
    public int queryCount() {
        return staffinfoMapper.queryCount();
    }

    @Override
    public EStaffinfo queryOne(String user, String password) {
        return staffinfoMapper.queryOne(user, password);
    }

    @Override
    public EStaffinfo queryLogin(String name) {
        return staffinfoMapper.queryLogin(name);
    }

    @Override
    public boolean updateName(String name, Integer id) {
        return staffinfoMapper.updateName(name, id)>0;
    }

    @Override
    public boolean updatePass(String pass, Integer id) {
        return staffinfoMapper.updatePass(pass, id)>0;
    }

    @Override
    public boolean updatePhone(String Phone, Integer id) {
        return staffinfoMapper.updatePhone(Phone,id)>0;
    }

    @Override
    public EStaffinfo queryById(Integer id) {
        return staffinfoMapper.queryById(id);
    }
}
